<div class="container-fluid maindiv">
  <div class="row-fluid">
    <div class="sidebar-nav-fixed" id="filterPanel">
  <!--Here I check if there are results for users,stories and/or interests at all and show the checkboxes for the filter accordingly...-->
      
            <div class="sidebar-nav-fixed">
              <div class="well sidebar-nav">
                <ul class="nav nav-list">
                  <li class="nav-header">Directory</li>
                  <li class="divider"></li>   
                  <li><a href="/users"><i class="icon-user"></i><font size="4%">Users</font></a></li>
                  <li><a href="/interests/list"><i class="icon-heart"></i><font size="4%">Interests</font></a></li>
                  <li><a href="/stories"><i class="icon-book"></i><font size="4%">Stories</font></a></li>
                  <li class="divider"></li>
                  <li><a href="/admins/statistics/all_users"><i class="icon-signal"></i><font size="4%">Statistics</font></a></li>
                  <li><a href="/logs"><i class="icon-list"></i><font size="4%">Logs</font></a></li>
                  <li class="divider"></li>
                  <li><a href="/admin_settings"><i class="icon-cog"></i><font size="4%">Settings</a></li>
                </ul>
              </div>
            <% if @message.nil? %>
              <div class="well sidebar-nav" style="margin-top: 20px; background-color: #f8f8f8;">
                <ul class="nav nav-list">
                  <li class="nav-header">Search for: </li>
                  <li class="divider"></li>
                  <li id="allResults"><i class="icon-user"></i><font size="4%"><%= link_to "All",
                    {:controller => 'admins', :action => 'search',:query => params[:autocomplete][:query], :autocomplete => {:query => params[:autocomplete][:query]} }%></font></a></li>
                  <li id="allUsers"><i class="icon-user"></i><font size="4%"><%= link_to "Users",
                    {:controller => 'admins', :action => 'all_results',:query => params[:autocomplete][:query], :autocomplete => {:query => params[:autocomplete][:query]}, :type => 1 }%></font></a></li>
                  <li id="allStories"><i class="icon-user"></i><font size="4%"><%= link_to "Interests",
                    {:controller => 'admins', :action => 'all_results',:query => params[:autocomplete][:query], :autocomplete => {:query => params[:autocomplete][:query]}, :type => 3 }%></font></a></li>
                  <li id="allInterests"><i class="icon-user"></i><font size="4%"><%= link_to "Stories",
                    {:controller => 'admins', :action => 'all_results',:query => params[:autocomplete][:query], :autocomplete => {:query => params[:autocomplete][:query]}, :type => 2 }%></font></a></li>
                </ul>
              </div>
            <% end %> 
        </div>
    </div>
      
  <!--The results of the three parts (users,stories,interests) will appear in this panel-->
    <div class="main-user-profile-page" >
      <% if @message.class == String %>
  <!--If there are no results found or if there is no query written in the search bar then a warning will appear to the admin informing him about that-->
        <div class="middle-user-profile-page-panel" id="noSearchQuery">
            <h2><%= @message %></h2>
        </div>
      <% else %>
	<!--If the users checkbox is checked, then the results of the users will be shown unless there are no results to show. I also add a button to view the statistics of each user and another button to view the remaining results of the users-->
      		<% if $users.length > 0 %>
      			<div class="middle-user-profile-page-panel" id="usersSearchResults">
        			<h2>Top Users Search Results</h2>
        			<% $users[0..2].each do |user| %>
        				<div class="well-user-component">
                   <a href="/users/<%= user.id%>"
                     style="display:block; float:left; height:100px;">
                    <% if not user.image? %>
                     <%= image_tag "logo.jpeg", :class=>"img-user-component" %>
                    <% else %>
                     <img src= "<%= user.image %>" width="80" style="height:100px"/>
                    <% end %>
                   </a>
                   <div style="padding-left:10px; margin-left:100px;">
                    <h3>
                    <% if user.name.nil? %>
                      <%= user.email.split("@")[0] %>
                    <% else %>
                      <%= user.name %>
                    <% end %>
                   </h3>
                   <%= link_to "Profile",
                   {:controller => 'users', :action => 'show',:id => user.id },
                    class: "interest-component-button-absolute btn btn-warning"%>
              
                   <h5>Email : <%=user.email%></h5>
                   <h5>Rank : <%= user.get_user_rank %></h5>
                   <%= link_to "Statistics",
                    {:controller => 'statistics', :action => 'users',:id => user.id },
                     class: "interest-component-button-absolute btn btn-primary"%>
                   <h5>Registration date : <%=time_ago_in_words(user.created_at) + " ago"%></h5>
              
                   <% if !(user.deactivated) %>
          
                       <span class="greenbadge"  style="width:100%" >Active</span>

                   <% else%>

                       <span class="redbadge"  style="width:100%">Deactivated</span>

                   <% end %>
                 </div>
                </div>
        			<%end%>
  					</div>
      		<% end %>
      
      <!--If the stories checkbox is checked, then the results of the stories will be shown unless there are no results to show. I also add a button to view the statistics of each story and another button to view the remaining results of the stories-->
    			<% if $stories.length > 0 %>
      			<div class="middle-user-profile-page-panel" id="storiesSearchResults">
        			<h2>Top Stories Search Results</h2>
       				<% $stories[0..2].each do |story| %>
        				<div class="well-story-component">
							<a href="/stories/<%= story.id%>"
							 style="display:block; float:left; height:100px;">
							 <%= image_tag "logo.jpeg", :class=>"img-story-component"%> 
							</a>
							<div style="padding-left:10px; margin-left:100px;">
								<h3>
									<%= story.title %>
								</h3>
								<%= link_to "More Info",
							    {:controller => 'stories', :action => 'show',:id => story.id },
							     class: "interest-component-button-absolute btn btn-warning"%>
								<h5> Rank : <%= story.get_story_rank_all_time %> </h5>
								<h5> Shares : <%= story.shares.count %> </h5>
								<%= link_to "Statistics", 
								{:controller => 'statistics', :action => 'stories',:id => story.id }, 
								class: "interest-component-button-absolute btn btn-primary"%>
								<h5> Fetched at : <%=time_ago_in_words(story.created_at) +" ago." %> </h5>
								 <span class="greenbadge"  style="width:100%" >Related Interest: <%=story.interest.name %></span>
							</div>
						</div>
        			<%end%>
  					</div>
					<% end %>
      
      <!--If the interests checkbox is checked, then the results of the interests will be shown unless there are no results to show. I also add a button to view the statistics of each interest and another button to view the remaining results of the interests-->
    			<% if $interests.length > 0 %>
      			<div class="middle-user-profile-page-panel" id="interestsSearchResults">
        			<h2>Top Interests Search Results</h2>
        			<% $interests[0..2].each do |interest| %>
        				<div class="well-interest-component">
                     <a href="/interests/<%= interest.id%>"
                     style="display:block; float:left; height:100px;">
                     <% if not interest.photo.file? %>
                       <%= image_tag "logo.jpeg", :class=>"img-user-component" %>
                     <% else %>
                       <img src= "<%= interest.photo.url(:small) if interest.photo.file? %>" width="80" style="height:100px"/>
                     <% end %> 
                     </a>
                     <div style="padding-left:10px; margin-left:100px;">
                      <h3>
                       <%= interest.name  %>
                      </h3>
                       <%= link_to "Interest", 
                       {:controller => 'interests', :action => 'show',:id => interest.id }, 
                      class: "interest-component-button-absolute btn btn-warning"%>
                      <h5>Rank : <%=interest.get_interest_rank%></h5>
                      <h5>No Of Stories: <%=interest.stories.count%></h5>
                      <%= link_to "Statistics", 
                        {:controller => 'statistics', :action => 'interests',:id => interest.id }, 
                        class: "interest-component-button-absolute btn btn-primary"%>
                      <h5>No Of Subscribers: <%=interest.adding_users.count%></h5>
                      <% if !(interest.deleted ) %>
                        <span class="greenbadge"  style="width:100%" >Active</span>
                      <% elsif interest.deleted %>
                        <span class="redbadge"  style="width:100%">Blocked</span>
                     <% end %>
                    </div>
                  </div>
        			<%end%>
  					</div>
     			<% end %>
  		<% end %>    
		</div>
	</div>
</div>
